import request from '../utils/request';

export async function getLineageData(
  dbType: string,
  querySql: string,
  columnName?: string,
  isCreateTable: boolean = false
) {
  return request('/api/lineage/analyze', {
    method: 'POST',
    data: { dbType, querySql, columnName, isCreateTable },
  });
}

export async function getDbTypes() {
  return request('/api/dbType', {
    method: 'GET',
  });
}

export async function getMatelakes() {
  return request('/api/mate/matelakes', {
    method: 'GET',
  });
}

export async function getCatalogs(mateLake) {
  // 构造查询参数
  const queryParams = new URLSearchParams({ mateLake }).toString();
  // 拼接完整的 URL
  const url = `/api/mate/catalogs?${queryParams}`;
  return request(url, {
    method: 'GET',
  });
}

export async function getSchemas(mateLake: string, catalog: string) {
  return request('/api/mate/schemas', {
    method: 'POST',
    data: { mateLake, catalog },
  });
}


export async function getLineageDataFromMate(
  mateLake: string,
  catalog: string,
  querySql: string,
  columnName?: string
) {
  return request('/api/mate/lineage/analyze', {
    method: 'POST',
    data: { mateLake, catalog, querySql, columnName },
  });
}
